package cn.good.yan.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * 资源服务器配置
 *
 * @author shengren.yan
 * @create 2024/10/14
 */
@Configuration
// 启用资源服务器配置
@EnableResourceServer
public class ResourceConfig extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                // 所有请求都必须认证，才能访问
                .anyRequest().authenticated()
                // 可以使用 and 来区分
                .and()
                // 放行该请
                .requestMatchers().antMatchers("/user/**");
    }

}
